/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package xmluebung2;

import java.awt.Color;
import java.util.Random;
import javax.swing.JPanel;

/**
 * Manages the logic for the selection of random panels as well as colorschemes.
 * 
 * @author Adrian Cieluch
 */
public class PanelManager {
    static ColorScheme scheme;
    
    /**
     * Sets the colorScheme.
     * 
     * @param schemeNumber predefined colorScheme by number
     */
    public static void setColorScheme(int schemeNumber) {
        ColorScheme s = null;
        schemeNumber--;
        switch(schemeNumber) {
            case 0:
                s = new ColorScheme(Color.white, Color.gray, Color.black);
                break;
            case 1:
                s = new ColorScheme(Color.gray, Color.white, Color.black);
                break;
            case 2:
                s = new ColorScheme(Color.gray, Color.black, Color.white);
                break;
            case 3:
                s = new ColorScheme(Color.white, Color.black, Color.gray);
                break;
            case 4:
                s = new ColorScheme(Color.black, Color.gray, Color.white);
                break;
            case 5:
                s = new ColorScheme(Color.black, Color.white, Color.gray);
                break;
            case 6:
                s = new ColorScheme(Color.darkGray, Color.gray, Color.green);
                break;
            case 7:
                s = new ColorScheme(Color.darkGray, Color.gray, Color.white);
                break;
            case 8:
                s = new ColorScheme(Color.darkGray, Color.gray, Color.yellow);
                break;
            case 9:
                s = new ColorScheme(Color.darkGray, Color.gray, Color.red);
                break;
            case 10:
                s = new ColorScheme(Color.darkGray, Color.red, Color.black);
                break;
            default:
                s = new ColorScheme(Color.darkGray, Color.black, Color.red);
                break;
        }
        
        scheme = s;
    }
    
    /**
     * Creates a random colorscheme.
     */
    public static void setRandomScheme() {
        Random r = new Random();
        scheme = new ColorScheme(new Color(r.nextInt(256), r.nextInt(256), r.nextInt(256)), new Color(r.nextInt(256), r.nextInt(256), r.nextInt(256)), new Color(r.nextInt(256), r.nextInt(256), r.nextInt(256)));
    }
    
    /**
     * Creates a new panel based on the mathmatical functions and returns it.
     * 
     * @param x x coordinate of the panel
     * @param y y coordinate of the panel
     * @param width width of the panel
     * @param height height of the panel
     * @return returns the randomly select Panel
     */
    public static JPanel setRandomPanel(int x, int y, int width, int height) {
    JPanel panel = null;
    Random r = new Random();
    int random = r.nextInt(11);

    switch(random) {
        case 0:
            panel = new Panel_x2(x, y, scheme, width, height);
            break;
        case 1:
            panel = new Panel_x3(x, y, scheme, width, height);
            break;
        case 2:
            panel = new Panel_rootx(x, y, scheme, width, height);
            break;
        case 3:
            panel = new Panel_sinx(x, y, scheme, width, height);
            break;
        case 4:
            panel = new Panel_cosx(x, y, scheme, width, height);
            break;
        case 5:
            panel = new Panel_1divx(x, y, scheme, width, height);
            break;
        case 6:
            panel = new Panel_xx(x, y, scheme, width, height);
            break;
        case 7:
            panel = new Panel_xdivsinx(x, y, scheme, width, height);
            break;
        case 8:
            panel = new Panel_xxdivsinx(x, y, scheme, width, height);
            break;
        case 9:
            panel = new Panel_rootxdivxx(x, y, scheme, width, height);
            break;
        case 10:
            panel = new Panel_rootxplusxdivx(x, y, scheme, width, height);
            break;
        default:
            panel = new Panel_sinx(x, y, scheme, width, height);
            break;
        }


    return panel;
    }
}
